package com.qianfeng.shopping.dao;

import com.qianfeng.shopping.entity.Account;

public class DiscountImp2 implements  Discount{
    @Override
    public double discountMoney(double totalMoney, Account account) {
        // 先满减后打折
        double m1 = totalMoney-(int)(totalMoney/1000 )*100;
        double result1 = m1*account.getLevel().getDiscount();
        System.out.println(result1);
        // 先打折后满减
        double m2 = totalMoney*account.getLevel().getDiscount();
        double result2 = m2-(int)(m2/1000 )*100;
        System.out.println(result2);
        return result1<result2?result1:result2;
    }
}
